package leetCode.competition;

public class Code_5523 {
  public int minOperations(String[] logs) {
    if (logs.length == 0) {
      return 0;
    }
    if (logs.length == 1 && logs[0].indexOf("/") < 0) {
      return 0;
    }
    int next = 0, back = 0;
    for (int i = 0; i < logs.length; i++) {
      if (logs[i].indexOf(".") < 0) {
        next++;
        continue;
      }
      if (logs[i].indexOf("..") >= 0) {
        if (next - back <= 0) {
          back--;
        }

        back++;
      }
    }
    return next - back >= 0 ? next - back : 0;
  }
}
